package site.teamo.biu.flink.web.controller;

import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;
import site.teamo.biu.flink.web.controller.model.BiuJSONResult;
import site.teamo.biu.flink.web.controller.model.executionengine.CreateExecutionEngineRequest;
import site.teamo.biu.flink.web.service.ExecutionEngineService;
import site.teamo.biu.flink.web.util.BiuJSONResultUtils;

import javax.annotation.Resource;

/**
 * @author haocongshun
 * @date 2023/12/06 14:35:27
 */
@Api(tags = "执行引擎")
@RestController
@RequestMapping("/api/execution-engine")
public class ExecutionEngineController {

    @Resource(name = "executionEngineServiceImpl")
    private ExecutionEngineService executionEngineService;

    @PostMapping("/create")
    public BiuJSONResult create(@RequestBody CreateExecutionEngineRequest request) {
        return BiuJSONResultUtils.ok(executionEngineService.createEngine(request.getName(), request.getType(), request.getContent()));
    }

    @GetMapping("/query-list")
    public BiuJSONResult list() {
        return BiuJSONResultUtils.ok(executionEngineService.list());
    }

}
